package com.utils.httphelper;

/*---------------------------另一个工程--------------------------------*/

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 展业推数时将处于拒绝状态的单子置为结束
 * @author zhaozongyi
 * @date 2016-4-21
 */
public class RefuseToEndForAPPServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
			throws ServletException, IOException {
		doPost(arg0, arg1);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void doPost(HttpServletRequest arg0, HttpServletResponse resp)
			throws ServletException, IOException {
		
		Map<String ,Object>  reqMap = new HashMap<String ,Object>();
		OutputStream out = null;
		ObjectOutputStream objectOut = null;
		
		Map<String ,Object>  map = new HashMap<String ,Object>();
		InputStream in = null;
		ObjectInputStream objectIn = null;
				
		boolean flag = false;
		try {
			in = arg0.getInputStream();
			objectIn = new ObjectInputStream(in);
			map = (Map<String, Object>) objectIn.readObject();
			String cardNo = (String) map.get("parameter");
			if(objectIn!=null){
				objectIn.close();
			}
			//这一步有没有可能直接从arg0内取得map
//			String applyCode = arg0.getParameter("applyCode");
//			String cardNo = arg0.getParameter("parameter");
			
			System.out.println(cardNo);
			reqMap.put("flag", flag);
		} catch (Exception e) {
			reqMap.put("flag", false);
		}finally{
			out = resp.getOutputStream();
			objectOut = new ObjectOutputStream(out);
			objectOut.writeObject(reqMap);
			try {
				if(in!=null){
					in.close();
				}
				
				if(out!=null){
					out.flush();
					out.close();
				}
				if(objectOut!=null){
					objectOut.flush();
					objectOut.close();
				}
				
			} catch (Exception e) {
				
			}
		}
		
	}
}
